package com.qf.flash.mvp.presenter;

import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.http.HttpManager;
import com.qf.flash.mvp.contract.SetRoleContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

/**
 * 描述: 设置角色
 * 2020/3/31 18:09
 */
public class SetRolePresenter extends BasePresenter<SetRoleContract.View> implements SetRoleContract.Presenter {
    @Override
    public void setRole(String orderId, String targetID, int roleType) {
        String uid = UserMgr.getInstance().getLoginUser().getUid();
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .GAME_SCORE(uid, orderId, targetID, roleType)
                .compose(RxUtils.handleResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<Object>(mRootView) {
                    @Override
                    public void onSuccess(Object o) {
                        mRootView.setRoleSuccess();
                    }
                })
        );
    }
}
